<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>基础数据管理-计划节点资料打印</title>
    <script src="/scripts/boot.js"></script>
    <link href="/scripts/daterangepicker/js/daterangepicker.min.css" rel="stylesheet" type="text/css" />
    <script src="/scripts/daterangepicker/js/moment.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/js/jquery.daterangepicker.min.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/ux.daterangepicker.js" type="text/javascript"></script>
    <link href="/scripts/daterangepicker/css/skin.css" rel="stylesheet" type="text/css" />
    <style>
        html body .searchbox .mini-buttonedit-icon
        {
            /*background:url(static/scripts/daterangepicker/search.gif) no-repeat 50% 50%;*/
        }
        .checkSpan{
            margin-left: 5px;
            margin-right: 5px;
            line-height: 30px;
        }
        .checkSpan .check{
            vertical-align: middle;
        }
    </style>
</head>
<body class="bg-white">
<div id="viewForm">
    <div class="title-info mb-20"><span>计划节点信息</span></div>
    <table class="table-bg" id="dataPrint" border="0" cellpadding="1" cellspacing="1" style="width:100%;table-layout:fixed;">
        <colgroup>
            <col width="135px"></col>
            <col width="100%"></col>
        </colgroup>
        <!--<tr>-->
            <!--<td class="text-titlebg"><span class="color-red">*</span>节点名称1</td>-->
            <!--<td>-->
                <!--<span class="checkSpan">-->
                    <!--<input type="checkbox" id="check1" value="123" name="name" class="check">-->
                    <!--<label for="check1">姓名</label>-->
                <!--</span>-->
            <!--</td>-->
        <!--</tr>-->
    </table>
    <div class="mini-fit"></div>
    <div class="chose-toolbar">
        <a class="chose-button" onclick="CloseWindow('close')">取消</a>
        <a class="chose-button save-button" onclick="view.preview()">预览</a>
    </div>
</div>
<script src="/scripts/res/js/common.js"></script>
<script type="text/javascript">

    var post_flag,form,state,datas,path1;
    var view = {
        init: function () {
            post_flag = false; //设置一个对象来控制是否进入AJAX过程
            // mini.parse();
            form = new mini.Form("#viewForm");
        },
        preview:function() {
            var url=new Array();
            var name=new Array();
            $("input[name='name']").each(function(){
                if($(this).is(':checked')){
                    var value,path;
                    value  =$(this).attr("val");
                	path=$(this).attr("url");
                    name.push(value);
                    url.push(path);
                    
                }
            });

            if(name.length==0 ){
                mini.alert('请选择需要预览的附件!');
                 return ;
             }

        	//window.open("/wordController/copyFolder?path=" + url+ "&fileName=" + name);
        	
            window.open("/wordController/copyFolder?path=" + url+ "&fileName=" + name);

            
            
            // if(arrs.length==0 ){
            //     alert('请选择数据!');
            //     return ;
            // }
            // location.href=ROOT+"/mims/customer.do?method=goGaiPai&ids="+arrs.join(",");
            // 
            /* mini.open({
                 url: "/program/monthlyPlan/file.html",
                 title: "预览文件", width: $(window.parent.document).width()-280, height: $(window.parent.document).height(),
                 onload: function () {
                	 console.log(path1)
                     var data = {"path":path1};
                     var iframe = this.getIFrameEl();
                     iframe.contentWindow.view.SetData(data);
                 },
                 ondestroy: function (action) {
            
                 }
             }); */
        },
//    数据展示
        SetData: function (data) {
            data = mini.clone(data);
            //跨页面传递的数据对象，克隆后才可以安全使用
            $.ajax({
                url:"/monthlyPlanExecution/dataPrintInfo?planNodeId=" + data.id,
                type: "post",
                success: function (text) {
                    console.log(text);
                    // var obj = JSON.parse(text);
                    // console.log(obj)
                    var dataPrint = $("#dataPrint");
                    var _tr;
                    for (var i=0;i<text.length;i++) {
                        _tr ='<tr>'+
                            '<td class="text-titlebg">'+text[i].node_name+'</td>'+
                            '<td id='+text[i].detailed_id+'>'+
                            '</td>'+
                        '</tr>';
                        dataPrint.append(_tr);
                        view.onLoadFile(text[i].detailed_id);
                    }
                }
            });
        },
        onLoadFile : function(id){
            $.ajax({
                url: "/fileCommon/loadFileList",
                type : "post",
                dataType: 'json',
                async: false,       //是否同步,默认true异步
                data:{"tableId":id,"tableName":"t_key_fruit_archives_detailed"}
            }).done(function(text) {
                if(text){
                    var div = $("#"+id);
                    var listFile = text;
                    for(var i=0;i<listFile.length;i++ ){
                        var file = listFile[i];
                        var a = '<span class="checkSpan"><input type="checkbox" id='+text[i].id+' val='+text[i].fileName+' url='+text[i].fileUrl+' name="name" class="check">'+
                            '<label for='+text[i].id+'>'+text[i].fileName+'</label></span>';
                        div.append(a);
                    }

                }
            });

        }
    };
    view.init();
</script>
</body>
</html>